package com.gao.mq.service;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gao.mq.constant.Constants;
import com.gao.mq.domain.MessageInfo;
import com.gao.mq.dto.ContentModel;
import com.gao.mq.dto.SmsContentModel;
import com.gao.mq.util.RedisUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;

import java.util.Random;
import java.util.concurrent.Future;

/**
 * 消息生产者
 */
@Service
public class MessageProducerService {

    private static final Logger logger = LoggerFactory.getLogger(MessageProducerService.class);

    @Autowired
    private RedisUtil redisUtil;

    /**
     * 发送消息
     * @param messageInfo
     * @return
     */
    public boolean sendMessage(MessageInfo messageInfo) {
        logger.info("发送消息 start");
        return redisUtil.leftPush(Constants.RedisMsgKey.REDIS_MSG_KEY(messageInfo.getMessageType()), messageInfo);
    }


}
